package com.meteor.downloader.videodownloader.utils.dialog

import android.content.Context
import android.os.Bundle
import android.view.Gravity
import androidx.appcompat.app.AppCompatDialog
import com.meteor.downloader.videodownloader.databinding.DialogCanNextMdmBinding
import com.meteor.downloader.videodownloader.dismissGoMdm

class DialogCanNextMdm(
    private val mContext: Context,
    private val title: Int? = null,
    private val body: Int? = null,
    private val nextTil: () -> Unit
) : AppCompatDialog(mContext) {
    private lateinit var mMdmBinding: DialogCanNextMdmBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mMdmBinding = DialogCanNextMdmBinding.inflate(layoutInflater)
        setContentView(mMdmBinding.root)
        setCancelable(true)

        title?.let { mMdmBinding.tvMdmTitle.text = mContext.getString(it) }
        body?.let { mMdmBinding.tvMdmBody.text = mContext.getString(it) }
        mMdmBinding.tvCancel.setOnClickListener { dismissGoMdm() }
        mMdmBinding.tvYes.setOnClickListener {
            dismissGoMdm()
            nextTil()
        }

        DialogMangerMdmUtils.changeWindowHalf(window, gravity = Gravity.CENTER)
    }
}